package com.bxait.toymail.order.config;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

/*
@description:
@ClassName AlipayConfig
@author Chen
@create 2023-05-21 0:54
@Version 1.0
*/
@Component
public class AlipayConfig {

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
//    @Value("${alipay.appid}")
    public String app_id = "2021000120615517";

    // 商户私钥，您的PKCS8格式RSA2私钥
//    @Value("${alipay.app-private-key}")
    public String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDeAE0N4TpJvEkOOdLpo8s5uEAweTNFQYVrIvaZMNEAy/f+aqzgzqatuTw50dDyf3Rd0bWciItBvMK3GucEgmJaIsCZd7qKVv5zS8s7TL/J8ybZi6QnSJZ4sIIqL5/0w5mjEtLGPWYX372HkgviYZOP9w4ye3coqkWzBpsg05467hgZXhNjKB0HSaiLAtqqqqe2KKE4A41GFrFkblX6i5rqVpfC6RwHTnWMIyEXaLihxrgJ83BsLnFXb+41bvhhAoZ9M3G/fc4QyyUy+m2w1ExTDIyBebaw1JIByhM8uLp9wW9TkFTfPswK7NrE1miXtzY6uGyKRGHHBzwMkdF1suwhAgMBAAECggEAV3rk4kBLeLziSOHOU9UAgykw2ikYZAUSrwojBHCxG1BE1BNzNk8YbUKeEea1IKnK0CGQIDPKNEhOrlrCiAtc+EnTfWYpstPfBs3qMt7mgIz5VSZqtDQtXzemwzrrHEdrplAHkKinL2cyR1bsqfNrc4KWLJxsczDNsGM9A+1/35Yw+pza4PLd5IduCM+Y1yYhYHACv0rArgAJi5P8JFuP9ES5AQOI08NfcEUdwPrj9QnZJHrZXEQTL7sJ0fH6Kl3hpILMBIRMioiqme35HJQwKNhr/MxN+aSrYauhuJZXTnDdCG0GtL0v9r/Sdy7xY7U+bHlr8t0QTsw8G4iEGbcqwQKBgQD6aafyhY7gXvaV4I6ekV6OCUgLzbAwod2xwpvpMCLeyTzOf4LGFak1pq94vC0MMvUIQ5iF0o2YpHpPvtqMyuO2Q6+/cAVfkbrEdvpnCoHumnhzUghEE04cB/DEpOvm3+NZyABXwzp4Y6EZRfDBicSHyIf0e4IR2pIUGVFTvEmtiQKBgQDi9FwYQ2Boctx1s/bSDat0+id6jGaxOHj2AChVLL9uBwXtkRyBll2jEXgoaPI1uhboDAXdks3OilB+qbFLnS2IrfdvG6ID+/G+6SM8cP9WpJQXElsbOVRUyMetk3Ke2kPVyue3YnV3Id7pDEpP52kMvXgf/STLf7pUO7qKxG572QKBgQD0uDKweUOTFFspR6Y5YtmkN3/YQTCRpm6Q3R4fOrKpRMMPD2APE3Yk/3v2ovfnNxlt9RlmlslYRk1eB6dv9oupQObNUL1/k1yRybCW6JboRr+1+5ImbTNlg4ERvBbqrxxxTlq/agSHSN5UY5yQl4GgLSJolBceOZuO1ts62QSr+QKBgEhpStD6/lGVBD4Rs1iFwATMo7f3//PfXsiueC/k3RcP6pZHzF6UST/0HPBXu5/kxdY3r89oPX3+p3wiTE0h0xte1il/GYxH4HPXEsUAEJfmXtGVq7fd7Mg4X21ENDf2z9nwqUnbgjsGdYbJwxQHc377HM6oCAtdr2ecvwHzdoTRAoGBAKi3VeZ7YF+yjqNlCSUB+H+EvqbZ/jRia9noBR82196KgSW/I4QATl6OpLcXlYP1sFCmwapKGrJ9wj2pxzKw7CdiIu1HmnwePESbwJ8fyT2VPaCxHmuT41rUHyJwkse+MS7Afo13G0mF8jJAf8TPaCUe0Rd0cRlSY1DMpCJfDDn1";
    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。

//    @Value("${alipay.alipay-public-key}")
    public String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApxvzTvOu/jMSN89bxTCWrWdpOtcypCj8Y28OxIBfYRfY2naSbfGxSlnQoK0Yu7gtbC54plM7FWPM5LkJGYoSfWp/zsW7Gj0RXeSC8Hnim1lA5m1BkIvJlzjE4IrOL1cW+JrJXJMtqTOjVVK1c6HprF5JOMSIATu4uUCEObNcALd5Nszo7fUMsgTgyRODBu5oGVEuSZWwbRHTkyyVQjfNZHgLrrOZM2Z7yjo7c2F2sj0vf/2392SWFFGEg53TovgAGWK0jHDEY5AdeQc4Snlh/5YwxdIuN1TsVBfEzfEOaGTm/l1rit7AXo0RPLjnhbMjcyNSusn1Y8+0u6Kpo4wJaQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    //public static String notify_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";
//    @Value("${alipay.notifyUrl}")
    public String notify_url = "http://497n86m7k7.52http.net/payed/notify";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    // public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

//    @Value("${alipay.returnUrl}")
    public String return_url = "http://order.toymail.com/memberOrder.html";

    // 签名方式
//    @Value("${alipay.signType}")
    public String sign_type = "RSA2";

    // 字符编码格式
//    @Value("${alipay.charset}")
    public String charset = "utf-8";

    // 支付宝网关
//    @Value("${alipay.gatewayUrl}")
    public String gatewayUrl= "https://openapi.alipaydev.com/gateway.do";


//    @Value("${alipay.format}")
    public String format = "json";

    // 日志输出地址
//    @Value("${alipay.logs}")
    public static String log_path;

    //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

